FROM osgeo/gdal:alpine-small-3.4.2

# update apk repo
RUN { echo 'http://mirrors.ustc.edu.cn/alpine/v3.12/main/'; echo 'http://mirrors.ustc.edu.cn/alpine/v3.12/community/'; } > /etc/apk/repositories
# install openjdk8-jre
ENV LANG=C.UTF-8
RUN { echo '#!/bin/sh'; echo 'set -e'; echo; echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; } > /usr/local/bin/docker-java-home && chmod +x /usr/local/bin/docker-java-home
ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk/jre
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin
ENV JAVA_VERSION=8u275
ENV JAVA_ALPINE_VERSION=8.275.01-r0
RUN set -x && apk add --no-cache openjdk8-jre="$JAVA_ALPINE_VERSION" && [ "$JAVA_HOME" = "$(docker-java-home)" ]

# install python
RUN apk update && apk add --no-cache python3 py3-numpy py3-gdal

# service
RUN mkdir -p /home/docker/service/scripts
RUN mkdir -p /home/docker/service/share
WORKDIR /home/docker/service
COPY filter-0.0.1-SNAPSHOT.jar /home/docker/service/filter-0.0.1-SNAPSHOT.jar
COPY filter.py /home/docker/service/scripts/filter.py
CMD java -jar filter-0.0.1-SNAPSHOT.jar --spring.profiles.active=test
EXPOSE 8080